{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Question 44\n",
    "\n",
    "### **Question:**\n",
    "\n",
    "> **_Write a program which can map() to make a list whose elements are square of numbers between 1 and 20 (both included)._**\n",
    "\n",
    "---\n",
    "\n",
    "### Hints:\n",
    "\n",
    "> **_Use map() to generate a list. Use lambda to define anonymous functions._**\n",
    "\n",
    "---\n",
    "\n",
    "\n",
    "\n",
    "**Solutions:**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "code_folding": []
   },
   "outputs": [],
   "source": [
    "def sqr(x):\n",
    "    return x * x\n",
    "\n",
    "\n",
    "squaredNumbers = list(map(sqr, range(1, 21)))\n",
    "print(squaredNumbers)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "# Question 45\n",
    "\n",
    "### **Question:**\n",
    "\n",
    "> **_Define a class named American which has a static method called printNationality._**\n",
    "\n",
    "---\n",
    "\n",
    "### Hints:\n",
    "\n",
    "> **_Use @staticmethod decorator to define class static method.There are also two more methods.To know more, go to this [link](https://realpython.com/blog/python/instance-class-and-static-methods-demystified/)._**\n",
    "\n",
    "---\n",
    "\n",
    "\n",
    "\n",
    "**Solutions:**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class American:\n",
    "    @staticmethod\n",
    "    def printNationality():\n",
    "        print(\"I am American\")\n",
    "\n",
    "\n",
    "american = American()\n",
    "american.printNationality()  # this will not run if @staticmethod does not decorates the function.\n",
    "# Because the class has no instance.\n",
    "\n",
    "American.printNationality()  # this will run even though the @staticmethod\n",
    "# does not decorate printNationality()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "# Question 46\n",
    "\n",
    "### **Question:**\n",
    "\n",
    "> **_Define a class named American and its subclass NewYorker._**\n",
    "\n",
    "---\n",
    "\n",
    "### Hints:\n",
    "\n",
    "> **Use class Subclass(ParentClass) to define a subclass.\\***\n",
    "\n",
    "---\n",
    "\n",
    "\n",
    "\n",
    "**Solutions:**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class American:\n",
    "    pass\n",
    "\n",
    "\n",
    "class NewYorker(American):\n",
    "    pass\n",
    "\n",
    "\n",
    "american = American()\n",
    "newyorker = NewYorker()\n",
    "\n",
    "print(american)\n",
    "print(newyorker)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
